-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support to conditionally add components #100
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes in this pull request involve substantial modifications to the Changes
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (6)
crates/gh-workflow-tailcall/src/workflow.rs (5)
67-68
: Simplify unnecessary borrowing and cloningThe expressions
(&cond).clone()
and(&build).clone()
unnecessarily borrow the values before cloning. You can call.clone()
directly oncond
andbuild
.Apply this diff to simplify the code:
- .cond((&cond).clone()) - .add_needs((&build).clone()) + .cond(cond.clone()) + .add_needs(build.clone())🧰 Tools
🪛 GitHub Check: Build and Test
[failure] 67-67:
this expression borrows a value the compiler would automatically borrow
[failure] 68-68:
this expression borrows a value the compiler would automatically borrow
74-74
: Simplify unnecessary borrowing and cloningThe expression
(&permissions).clone()
needlessly borrowspermissions
before cloning. You can call.clone()
directly onpermissions
.Apply this diff:
- .permissions((&permissions).clone()) + .permissions(permissions.clone())🧰 Tools
🪛 GitHub Check: Build and Test
[failure] 74-74:
this expression borrows a value the compiler would automatically borrow
79-79
: Simplify unnecessary borrowing and cloningThe use of
(&cond).clone()
is redundant. You can simplify it by cloningcond
directly.Apply this diff:
- .cond((&cond).clone()) + .cond(cond.clone())🧰 Tools
🪛 GitHub Check: Build and Test
[failure] 79-79:
this expression borrows a value the compiler would automatically borrow
84-84
: Simplify unnecessary borrowing and cloningSimilarly,
(&build).clone()
can be simplified by cloningbuild
directly without borrowing.Apply this diff:
- .add_needs((&build).clone()) + .add_needs(build.clone())🧰 Tools
🪛 GitHub Check: Build and Test
[failure] 84-84:
this expression borrows a value the compiler would automatically borrow
97-97
: Simplify unnecessary borrowing and cloningIn this line,
(&build).clone()
can be simplified tobuild.clone()
.Apply this diff:
- .add_job("build", (&build).clone()) + .add_job("build", build.clone())🧰 Tools
🪛 GitHub Check: Build and Test
[failure] 97-97:
this expression borrows a value the compiler would automatically borrowcrates/gh-workflow/src/workflow.rs (1)
104-112
: Consider refactoring to reduce code duplication in conditional methodsMultiple methods (
add_job_when
,add_event_when
,add_env_when
,add_step_when
,add_env_when
inJob
,add_needs_when
,add_with_when
) share a similar pattern for conditionally adding elements based on a boolean condition. Consider refactoring these methods to reduce code duplication, possibly through a generic helper function or macro.Also applies to: 145-153, 163-171, 267-275, 296-303, 312-319, 582-589
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
crates/gh-workflow-tailcall/src/workflow.rs
(2 hunks)crates/gh-workflow/src/workflow.rs
(6 hunks)
🧰 Additional context used
🪛 GitHub Check: Build and Test
crates/gh-workflow-tailcall/src/workflow.rs
[failure] 67-67:
this expression borrows a value the compiler would automatically borrow
[failure] 68-68:
this expression borrows a value the compiler would automatically borrow
[failure] 74-74:
this expression borrows a value the compiler would automatically borrow
[failure] 79-79:
this expression borrows a value the compiler would automatically borrow
[failure] 84-84:
this expression borrows a value the compiler would automatically borrow
[failure] 97-97:
this expression borrows a value the compiler would automatically borrow
🔇 Additional comments (12)
crates/gh-workflow-tailcall/src/workflow.rs (5)
44-44
: Initialization of Rust flags is correct
Setting RustFlags::deny("warnings")
ensures that all Rust compiler warnings are treated as errors, promoting code quality.
46-54
: Event configuration is correctly set
The event
variable is properly configured to trigger on pushes to "main" and pull request events (Opened, Synchronize, Reopened) targeting the "main" branch.
56-58
: Conditional logic for workflow execution is appropriate
The conditions is_main
and is_push
are correctly combined to determine when the workflow should execute, ensuring it runs only on pushes to the "main" branch.
Line range hint 103-134
: Conditional addition of benchmarking step is well-implemented
Using add_step_when
to conditionally add the "Cargo Bench" step based on the benchmarks
flag enhances the flexibility and readability of the workflow configuration.
140-140
: Streamlined conversion to GitHub workflow
Utilizing value.to_github_workflow()
in the From<Workflow>
implementation simplifies the conversion process and improves code clarity.
crates/gh-workflow/src/workflow.rs (7)
104-112
: Conditional job addition method is well-designed
The add_job_when
method enhances the Workflow
struct by allowing jobs to be added conditionally, increasing flexibility.
145-153
: Conditional event addition improves configurability
The add_event_when
method allows events to be added to the workflow based on a condition, enhancing configurability.
163-171
: Conditional environment variable addition is appropriate
The add_env_when
method enables conditional addition of environment variables to the workflow, maintaining consistency with other conditional methods.
267-275
: Conditional step addition in Job
struct is well-implemented
The add_step_when
method allows steps to be added to a job conditionally, improving the expressiveness of job configurations.
296-303
: Conditional environment variable addition in Job
The add_env_when
method in the Job
struct allows for conditional addition of environment variables, enhancing flexibility.
312-319
: Conditional dependency addition in Job
The add_needs_when
method enables conditional addition of job dependencies, promoting dynamic workflow definitions.
582-589
: Conditional input addition in Step<Use>
The add_with_when
method provides the ability to conditionally add input parameters to a step, enhancing the configurability of actions.
v
prefix fromuses
APISummary by CodeRabbit
New Features
Bug Fixes
Refactor